# Validate Subsequence

# [1, 2, 3, 4]
#             ^arrayIdx
# [1, 3] True
#       ^seqIdx == len(subsequence)


# [1, 2, 5] False
#        ^seqIdx = 2 != len(subsequence)

# [1, 2] True


# [2, 4] True
# [2, 1] False
# [4, 2] False
# [1, 2, 3, 4] True
# Subsequence
# * Same elements
# * Same orders


# Write a function which takes two parameters (参数)：
# Parameters:
# - origin array
# - subsequence
# Return: Bool
# If subsequence is a valid subsequene of the origin array
def validateSubsequence(array, subsequence):
  arrayIdx = 0
  seqIdx = 0

  while arrayIdx < len(array) and seqIdx < len(subsequence):
    if array[arrayIdx] == subsequence[seqIdx]:
      seqIdx += 1

    arrayIdx += 1
  
  return seqIdx == len(subsequence)

print(validateSubsequence([1, 2, 3, 4], [1, 2, 3]))
